package 牛客.完美世界.背包;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int wps = sc.nextInt();//物品数
        double gmax = sc.nextInt();//重量最大值
        int money = 0;
        double  wuzl[][] = new double[wps][2];
        double  bz[] = new double[wps];
        for (int i= 0;i<wps;i++){
            wuzl[i][0] = sc.nextInt();//重量
        }
        for (int i= 0;i<wps;i++){
            wuzl[i][1] = wuzl[i][0]/(double) sc.nextInt();//最大比值
            bz[i] = wuzl[i][1];
        }
        Arrays.sort(bz);
        while(true){
            int a = bz.length-1;
            for(int i=0;i<wuzl.length;i++){
                if(bz[a]==wuzl[i][1]);
                gmax = gmax - wuzl[i][0];
                if (gmax<0.0){
                    System.out.println(money);
                    return;
                }else{
                    money = money + Integer.parseInt(String.valueOf(wuzl[i][0] * wuzl[i][0]));
                }
            }
        }
    }
}
